package com.fs.service.impl;

import com.fs.mapper.InventoryMapper;
import com.fs.pojo.Inventory;
import com.fs.service.InventoryToService;
import com.fs.vo.Condition;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author python_boy
 * @fileName InventoryToServiceImpl
 * @date 2024/10/17 17:07
 * @description
 **/
@Service
public class InventoryToServiceImpl implements InventoryToService {
    @Autowired
    private InventoryMapper inventoryMapper;

    @Override
    public PageInfo<Inventory> selectAll(Condition<Inventory> condition) {
        PageHelper.startPage(condition.getPage(), condition.getCount());
        List<Inventory> whInvInventories = inventoryMapper.selectAll(condition.getSearch());
        return new PageInfo<>(whInvInventories);
    }

    /**
     * 删除库存单
     * @param inventoryId 库存编号
     * @return 影响行数
     */
    @Override
    public int deleteInventory(Integer inventoryId) {
        return inventoryMapper.deleteById(inventoryId);
    }

    /**
     * 修改库存单
     * @param inventory 库存单对象
     * @return 影响行数
     */
    @Override
    public int updateInventory(Inventory inventory) {
        return inventoryMapper.updateById(inventory);
    }

    @Override
    public int insertInventory(Inventory inventory) {
        return 0;
    }
}
